<?php

/**
 * Created by Sven.
 * Date: 2016/12/25
 * Time: 12:31
 */
abstract class Action {

    protected $model; // ManageModel 对象
    protected $tpl; // 模板对象

    public function __construct($_tpl, $_model = null) {
        if ( !isset( $_tpl )  ||  !($_tpl instanceof   Templates) ) {
            exit( '模板对象传入错误' );
        }
        $this->tpl = $_tpl;
        // 1 创建实Manage体对象
        $this->model = $_model;
        // 2 进行一些列的控制操作
//        $this->action();
    }

    public abstract function  action();

    // page 方法有共性，可以抽取到父类中
    public function page($_total, $_page_size){
        $_page = new Page($_total, $_page_size ) ;
        $this->tpl->assign('page',  $_page->fPageHtml());
        $this->tpl->assign('page_base',   ($_page->currPage - 1) * PAGE_SIZE);
        $this->model->limit = $_page->limit;
    }

}